package com.leyou.common.advice;

import com.leyou.common.exceptions.LyException;
import com.leyou.common.vo.ExcrptionResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 处理请求和响应的方法
 *
 * @version V1.0
 * @package com.leyou.common.advice
 * @description:
 * @author: pc
 * @date: 2019/6/22 20:01
 */
@ControllerAdvice
public class BaseExceptionAdvice {

    @ExceptionHandler(LyException.class)
    public ResponseEntity<ExcrptionResult> handlerException(LyException e) {
        e.printStackTrace();
        return ResponseEntity.status(e.getStatus()).body(new ExcrptionResult(e));
    }
}
